<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <meta name="baidu-site-verification" content="code-oLqr5o013S">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"shaojunying.github.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":true,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta property="og:type" content="website">
<meta property="og:title" content="Shaojunying&#39;s Blog">
<meta property="og:url" content="https://shaojunying.github.io/index.html">
<meta property="og:site_name" content="Shaojunying&#39;s Blog">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="邵俊颖">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://shaojunying.github.io/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>Shaojunying's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="Shaojunying's Blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Shaojunying's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">35</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">55</span></a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

  <a href="https://github.com/shaojunying" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/04/06/AOP%E4%BB%A3%E7%90%86%E5%A4%B1%E6%95%88%E7%9A%84%E4%B8%A4%E7%A7%8D%E6%83%85%E5%86%B5/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/04/06/AOP%E4%BB%A3%E7%90%86%E5%A4%B1%E6%95%88%E7%9A%84%E4%B8%A4%E7%A7%8D%E6%83%85%E5%86%B5/" class="post-title-link" itemprop="url">AOP代理失效的两种情况</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-04-06 19:58:34 / 修改时间：19:58:40" itemprop="dateCreated datePublished" datetime="2021-04-06T19:58:34+08:00">2021-04-06</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="被代理对象的private方法不能被代理"><a href="#被代理对象的private方法不能被代理" class="headerlink" title="被代理对象的private方法不能被代理"></a>被代理对象的private方法不能被代理</h2><ul>
<li>cdlib技术使用子类来代理父类，子类看不到父类的private，也就无法代理private方法。</li>
<li>JDK动态代理是基于接口来实现的，而接口不允许有private方法，也就不会有出现这个问题。</li>
</ul>
<h2 id="调用类内其他方法"><a href="#调用类内其他方法" class="headerlink" title="调用类内其他方法"></a>调用类内其他方法</h2><ul>
<li>如果方法a()调用处于同一个类内的方法b()，那么相当于this.b()，这里的this代表没有被代理的方法。</li>
</ul>
<p>为了解决这个问题，可以使用Autowired引入被代理之后的类，进而使用（被代理后的对象）调用类内方法。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/04/04/Spring%E8%A7%A3%E5%86%B3%E5%BE%AA%E7%8E%AF%E4%BE%9D%E8%B5%96/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/04/04/Spring%E8%A7%A3%E5%86%B3%E5%BE%AA%E7%8E%AF%E4%BE%9D%E8%B5%96/" class="post-title-link" itemprop="url">Spring解决循环依赖</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-04-04 14:09:29 / 修改时间：14:09:56" itemprop="dateCreated datePublished" datetime="2021-04-04T14:09:29+08:00">2021-04-04</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <blockquote>
<p><a target="_blank" rel="noopener" href="https://www.javazhiyin.com/70070.html">跳出源码地狱，Spring巧用三级缓存解决循环依赖-原理篇-Java知音</a></p>
</blockquote>
<h2 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h2><p>使用两级缓存即可解决循环依赖问题，但是Spring还需要支持AOP，对象被AOP之后会生成一个新的对象，如果在将实例注入之后再进行AOP，那么两个地方的对象将不一致。因此使用三级缓存，将对象的AOP提前到实例化进行。</p>
<h2 id="三级缓存的过程"><a href="#三级缓存的过程" class="headerlink" title="三级缓存的过程"></a>三级缓存的过程</h2><ol>
<li>尝试获取一个bean，发现bean不存在，于是实例化该bean，并放入三级缓存。</li>
<li>第二次尝试获取该bean，从三级缓存中找到bean，对该实例执行AOP，放入二级缓存并返回。</li>
<li>在初始化工作彻底完成之后，Spring将bean放入一级缓存，并从二三级缓存中删除。</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/04/04/%E3%80%8A%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E3%80%8B%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/04/04/%E3%80%8A%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E3%80%8B%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" class="post-title-link" itemprop="url">《计算机网络》学习笔记</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-04-04 14:03:37 / 修改时间：14:07:31" itemprop="dateCreated datePublished" datetime="2021-04-04T14:03:37+08:00">2021-04-04</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="网络模型"><a href="#网络模型" class="headerlink" title="网络模型"></a>网络模型</h1><h2 id="五层网络模型"><a href="#五层网络模型" class="headerlink" title="五层网络模型"></a>五层网络模型</h2><p>分为应用层、传输层、网络层、数据链路层、物理层。</p>
<h2 id="现实中的网络模型"><a href="#现实中的网络模型" class="headerlink" title="现实中的网络模型"></a>现实中的网络模型</h2><p>将<strong>五层网络模型</strong>中的数据链路层和物理层合并为网络接口层</p>
<h2 id="OSI七层网络模型"><a href="#OSI七层网络模型" class="headerlink" title="OSI七层网络模型"></a>OSI七层网络模型</h2><p>将<strong>五层网络模型</strong>中的应用层拆分为会话层、表示层、应用层。</p>
<h1 id="各层的作用"><a href="#各层的作用" class="headerlink" title="各层的作用"></a>各层的作用</h1><ul>
<li><strong>物理层</strong>。将01比特从一台节点通过物理链路传递到另一个节点</li>
<li><strong>数据链路层</strong>。将数据分组从一个节点传递到另一个节点，同时提供差错检测和纠正的功能。</li>
<li><strong>网络层</strong>。将数据包从一台主机传递到另一台主机，提供的是一种尽力而为的服务。</li>
<li><strong>传输层</strong>。提供应用进程之间的数据传输服务。</li>
<li><strong>应用层</strong>。使用一些具体的协议传输数据。这些协议如HTTP、DNS、FTP、SMTP等。</li>
</ul>
<h1 id="应用层"><a href="#应用层" class="headerlink" title="应用层"></a>应用层</h1><h2 id="SMTP和HTTP"><a href="#SMTP和HTTP" class="headerlink" title="SMTP和HTTP"></a>SMTP和HTTP</h2><p>HTTP是一个”拉”协议。客户端发起请求之后服务端发送响应。</p>
<p>SMTP是一个“推”协议。发送方mail服务器直接将邮件推到接收方服务器上。</p>
<h2 id="DNS工作原理"><a href="#DNS工作原理" class="headerlink" title="DNS工作原理"></a>DNS工作原理</h2><p>每个ISP通常都有一个本地DNS服务器</p>
<ol>
<li>主机想要获取一个域名对应的IP地址，则向本地DNS服务器发送请求。</li>
<li>本地DNS依次向根服务器以及各级服务器发送请求获取域名对应的IP地址（如果已有缓存则不用发送请求）。</li>
</ol>
<p>其中主机向本地DNS服务器发送请求是<strong>递归查询</strong>，本地DNS服务器向其他服务器发送请求是<strong>迭代查询</strong>。</p>
<h1 id="运输层"><a href="#运输层" class="headerlink" title="运输层"></a>运输层</h1><h2 id="运输层提供的基本服务"><a href="#运输层提供的基本服务" class="headerlink" title="运输层提供的基本服务"></a>运输层提供的基本服务</h2><ul>
<li>数据交付</li>
<li>差错检测</li>
</ul>
<p>这也是UDP提供的仅有的两种服务。</p>
<h2 id="TCP提供的额外的服务"><a href="#TCP提供的额外的服务" class="headerlink" title="TCP提供的额外的服务"></a>TCP提供的额外的服务</h2><ul>
<li>可靠数据传输（包括序号、确认、定时器、流量控制）</li>
<li>拥塞控制</li>
</ul>
<h2 id="TCP的演化"><a href="#TCP的演化" class="headerlink" title="TCP的演化"></a>TCP的演化</h2><h3 id="停等协议（每次只发一条数据，确认后发送下一条数据）"><a href="#停等协议（每次只发一条数据，确认后发送下一条数据）" class="headerlink" title="停等协议（每次只发一条数据，确认后发送下一条数据）"></a>停等协议（每次只发一条数据，确认后发送下一条数据）</h3><ol>
<li>为了解决数据包出错的问题，引入<strong>确认</strong>（肯定确认和否定确认）机制。</li>
<li>确认帧可能受损，如果收到一个损坏的帧，就重发数据包。为了区分是重传还是新数据包，引入<strong>序号</strong>机制。</li>
<li>为了解决丢包问题，引入<strong>定时器</strong>机制。</li>
</ol>
<h3 id="流水线可靠数据传输协议"><a href="#流水线可靠数据传输协议" class="headerlink" title="流水线可靠数据传输协议"></a>流水线可靠数据传输协议</h3><ul>
<li><strong>回退N步。</strong><ul>
<li>采用<strong>累计确认</strong></li>
<li>超时时发送方重传所有未确认分组</li>
</ul>
</li>
<li><strong>选择重传。</strong><ul>
<li>接收方缓存接受到的失序分组</li>
<li>接收到[recv_base - N, recv_base - 1] 和[recv_base, recv_base + N - 1]都需要发送ACK</li>
<li>窗口大小应该小于等于序号区间的一半。</li>
</ul>
</li>
</ul>
<h2 id="TCP的可靠数据传输"><a href="#TCP的可靠数据传输" class="headerlink" title="TCP的可靠数据传输"></a>TCP的可靠数据传输</h2><ul>
<li>累计确认。（发送确认帧时说明之前的帧都已收到）</li>
<li>超时间隔加倍。（超时的时候定时器的间隔加倍，收到ACK后会重新计算超时间隔）</li>
<li>快速重传：如果收到失序的数据，冗余发送3个ACK</li>
</ul>
<h2 id="TCP：回退N-or-选择重传"><a href="#TCP：回退N-or-选择重传" class="headerlink" title="TCP：回退N or 选择重传"></a>TCP：回退N or 选择重传</h2><p>TCP算是两者的结合体，使用累计确认的方法，但是接收方会缓存失序的帧。</p>
<h2 id="TCP的流量控制"><a href="#TCP的流量控制" class="headerlink" title="TCP的流量控制"></a>TCP的流量控制</h2><ul>
<li><strong>接收窗口大小 = 缓冲区大小 - 已接收但是没有被上层使用的数据</strong></li>
<li>为了让发送方不会淹没接受方，发送方的<strong>已发送未确认数据大小应该≤接收窗口大小</strong></li>
</ul>
<h2 id="TCP的拥塞控制"><a href="#TCP的拥塞控制" class="headerlink" title="TCP的拥塞控制"></a>TCP的拥塞控制</h2><p><strong>cwnd</strong>表示拥塞窗口大小，MSS为TCP的最大分段大小。</p>
<p><strong>已发送未确认数据大小应该≤接收窗口大小 并且 ≤ 拥塞窗口大小</strong></p>
<ul>
<li>慢启动。每次收到一个ACK，cwnd变为原来的2次方，超时则恢复为1</li>
<li>拥塞避免。每次收到ACK只增加（MSS（MSS/cwnd））</li>
<li>快速恢复。每次收到冗余ACK只增加MSS</li>
</ul>
<p>超时的时候threshold被设置为cwnd/2</p>
<h3 id="转化关系"><a href="#转化关系" class="headerlink" title="转化关系"></a>转化关系</h3><p><img src="1.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/96c6cefd-9e62-4cc9-a60b-578e5c358ab8/Untitled.png"></p>
<h1 id="网络层（数据层面）"><a href="#网络层（数据层面）" class="headerlink" title="网络层（数据层面）"></a>网络层（数据层面）</h1><h2 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h2><ul>
<li>网络层提供两种功能：<ul>
<li><strong>转发。</strong>当一个分组到达网络层时，网络层应该将它移动到合适的出口。</li>
<li><strong>路由选择。</strong>决定分组到目的地应该走的路径。</li>
</ul>
</li>
<li>网络层提供一种尽力而为的交付模式</li>
</ul>
<h2 id="路由器的工作原理"><a href="#路由器的工作原理" class="headerlink" title="路由器的工作原理"></a>路由器的工作原理</h2><ul>
<li>路由器匹配时采用<strong>最长前缀匹配原则</strong>从而进行路由选择</li>
<li>丢包问题<ul>
<li><strong>输入队列丢包。</strong>不同输入队列的分组准备前往同一个输出队列（交换的速度<strong>没有足够快</strong>），第一个包后面的包将会排队，进而在队列满的时候将会发生丢包。</li>
<li><strong>输出队列丢包</strong>。如果交换速度<strong>足够快</strong>，多个输入收到的包准备前往相同的输出口，输出队列将会排队，进而发生丢包</li>
</ul>
</li>
</ul>
<h2 id="IPv4"><a href="#IPv4" class="headerlink" title="IPv4"></a>IPv4</h2><h3 id="报文格式"><a href="#报文格式" class="headerlink" title="报文格式"></a>报文格式</h3><p>数据包格式</p>
<p>版本 首部长度 服务类型 数据包长度</p>
<p>16位标识         标志位 13位片偏移</p>
<p>寿命 上层协议 校验和</p>
<p>源IP</p>
<p>目的IP</p>
<ul>
<li><strong>服务类型</strong>可用来区分实时流量和非实时流量</li>
<li><strong>标识 标志 片偏移</strong>：数据链路层有MTU最大传输单元，如果IP长度超过MTU，路由器需要将其拆分。（到目的地再被组装）。</li>
<li><strong>首部校验和</strong>：将首部每两个字节看成一个数，相加的和作为校验和。(TCP的校验和计算整个数据报，而IP的校验和只计算首部)</li>
<li><strong>上层协议</strong>：目的地根据该字段选择将数据交给哪一层。</li>
</ul>
<h2 id="DHCP（动态主机配置协议）"><a href="#DHCP（动态主机配置协议）" class="headerlink" title="DHCP（动态主机配置协议）"></a>DHCP（动态主机配置协议）</h2><p>DHCP是使用UDP进行传递的。</p>
<ol>
<li>客户广播一条ICMP查询报文，获取可用的IP地址（源IP为0.0.0.0，目标IP为255.255.255.255）</li>
<li>ICMP分配一个IP，并生成并广播ICMP响应报文（源IP为服务器IP，目标IP为255.255.255.255）（可能客户所在子网有多个ICMP服务器，所以客户需要选择一个并进行确认）。</li>
<li>客户端广播一条请求报文，请求将某一IP设置为自己的IP。</li>
<li>服务端响应ACK报文，客户端将该IP作为自己的IP。</li>
</ol>
<h2 id="NAT（本地地址转换）"><a href="#NAT（本地地址转换）" class="headerlink" title="NAT（本地地址转换）"></a>NAT（本地地址转换）</h2><p>路由器维护一个NAT表，分别存储局域网IP：端口和广域网IP：端口的对应关系，在数据包进出的时候对IP进行转换，进而完成使用一个IP地址完成最高6万（取决于端口的数量）个用户的联网工作。</p>
<h2 id="IPv6"><a href="#IPv6" class="headerlink" title="IPv6"></a>IPv6</h2><p>IPv4对比IPv6</p>
<ul>
<li><strong>分片字段被删除。</strong>如果IP分组过大，路由器将向源主机发送一个”分组过大”ICMP报文。分片工作留给源主机完成。</li>
<li>首部校验和被删除。每次TTL发生变化，都需要重新计算校验和，工作量较大，因此在IPv6中该字段被删除。</li>
</ul>
<h1 id="网络层（控制层面）"><a href="#网络层（控制层面）" class="headerlink" title="网络层（控制层面）"></a>网络层（控制层面）</h1><h2 id="路由选择算法"><a href="#路由选择算法" class="headerlink" title="路由选择算法"></a>路由选择算法</h2><h3 id="链路状态协议（集中式）"><a href="#链路状态协议（集中式）" class="headerlink" title="链路状态协议（集中式）"></a>链路状态协议（集中式）</h3><p>每个节点维护整个子网的链路状态，进而计算出源节点到目标节点的花销，使用Dijkstra算法。</p>
<h3 id="距离矢量协议（分布式）"><a href="#距离矢量协议（分布式）" class="headerlink" title="距离矢量协议（分布式）"></a>距离矢量协议（分布式）</h3><p>每个节点向直接邻居发送当前到各个节点的最短路径，同时接受邻居的信息并更新，直到自己的各最短路径不再发生变化。</p>
<h2 id="ICMP（互联网控制信息报文）"><a href="#ICMP（互联网控制信息报文）" class="headerlink" title="ICMP（互联网控制信息报文）"></a>ICMP（互联网控制信息报文）</h2><p>ping和traceroute都使用该报文</p>
<h1 id="数据链路层"><a href="#数据链路层" class="headerlink" title="数据链路层"></a>数据链路层</h1><p>通过单一信道，将数据从一个节点移动到相邻的节点。</p>
<h2 id="差错检测和纠正"><a href="#差错检测和纠正" class="headerlink" title="差错检测和纠正"></a>差错检测和纠正</h2><ul>
<li>奇偶校验</li>
<li>循环冗余校验</li>
</ul>
<h2 id="可靠重传"><a href="#可靠重传" class="headerlink" title="可靠重传"></a>可靠重传</h2><p>数据链路层的可靠重传保证了在链路上纠错，而不是传输层或应用层的端到端重传。</p>
<h2 id="多路访问控制协议"><a href="#多路访问控制协议" class="headerlink" title="多路访问控制协议"></a>多路访问控制协议</h2><h3 id="信道划分协议"><a href="#信道划分协议" class="headerlink" title="信道划分协议"></a>信道划分协议</h3><p>时分复用 频分复用</p>
<h3 id="随机接入协议"><a href="#随机接入协议" class="headerlink" title="随机接入协议"></a>随机接入协议</h3><p>纯ALOHA、时隙ALOHA、CSMA、CSMA/CD</p>
<h3 id="轮流协议"><a href="#轮流协议" class="headerlink" title="轮流协议"></a>轮流协议</h3><h2 id="ARP协议-地址解析协议"><a href="#ARP协议-地址解析协议" class="headerlink" title="ARP协议(地址解析协议)"></a>ARP协议(地址解析协议)</h2><p>每个主机上都会维护一个ARP表，里面存储子网内的IP和MAC地址的对应关系。想把数据传递到子网内的下一个节点时，就将目标节点的MAC地址设置为目标MAC地址。</p>
<p>MAC地址通过查询ARP获取，如果ARP表中不存在，则构造一个ARP分组并在子网内广播。目标主机收到分组之后返回自己的MAC地址。（使用的是MAC广播地址，全是F）</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/02/07/Java%E4%B8%ADHashMap%E4%B8%BA%E4%BB%80%E4%B9%88%E7%BA%BF%E7%A8%8B%E4%B8%8D%E5%AE%89%E5%85%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/07/Java%E4%B8%ADHashMap%E4%B8%BA%E4%BB%80%E4%B9%88%E7%BA%BF%E7%A8%8B%E4%B8%8D%E5%AE%89%E5%85%A8/" class="post-title-link" itemprop="url">Java中HashMap为什么线程不安全</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-07 20:57:11" itemprop="dateCreated datePublished" datetime="2021-02-07T20:57:11+08:00">2021-02-07</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-04 13:42:02" itemprop="dateModified" datetime="2021-04-04T13:42:02+08:00">2021-04-04</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="Java中的HashMap扩容方法的演变"><a href="#Java中的HashMap扩容方法的演变" class="headerlink" title="Java中的HashMap扩容方法的演变"></a>Java中的HashMap扩容方法的演变</h2><h3 id="Java7及以前"><a href="#Java7及以前" class="headerlink" title="Java7及以前"></a>Java7及以前</h3><h4 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h4><p>Java7之前使用的是头插法，可能在插入时造成环</p>
<h4 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">transfer</span><span class="params">(Entry[] newTable, <span class="keyword">boolean</span> rehash)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">int</span> newCapacity = newTable.length;</span><br><span class="line">    <span class="keyword">for</span> (Entry&lt;K,V&gt; e : table) &#123;</span><br><span class="line">        <span class="keyword">while</span>(<span class="keyword">null</span> != e) &#123;</span><br><span class="line">            Entry&lt;K,V&gt; next = e.next;</span><br><span class="line">            <span class="keyword">if</span> (rehash) &#123;</span><br><span class="line">                e.hash = <span class="keyword">null</span> == e.key ? <span class="number">0</span> : hash(e.key);</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">int</span> i = indexFor(e.hash, newCapacity);</span><br><span class="line">            e.next = newTable[i];</span><br><span class="line">            newTable[i] = e;</span><br><span class="line">            e = next;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h5 id="造成环的情况演示"><a href="#造成环的情况演示" class="headerlink" title="造成环的情况演示"></a>造成环的情况演示</h5><p><a target="_blank" rel="noopener" href="https://cloud.tencent.com/developer/article/1595438?from=information.detail.hashmap%E5%A4%B4%E6%8F%92%E6%B3%95%E5%B9%B6%E5%8F%91%E6%97%B6%E6%AD%BB%E5%BE%AA%E7%8E%AF">参考链接</a></p>
<p><strong>造成环的关键代码是<code>Entry&lt;K,V&gt; next = e.next;</code></strong></p>
<p>图示演示</p>
<p><img src="hashmap1.png"></p>
<h3 id="Java8的改进"><a href="#Java8的改进" class="headerlink" title="Java8的改进"></a>Java8的改进</h3><p>从Java8开始,hashmap的头插法被改成了尾插法,从而可以避免形成环.但是,仍然有线程安全问题.</p>
<ul>
<li>如果某个桶中没有元素,两个线程同时向桶中put元素,会导致有一个线程put的元素被覆盖掉</li>
<li>两个进程同时进行size++,也会发生错误</li>
</ul>
<p>因此如果想要保证线程安全,还是需要使用ConcurrentHashMap</p>
<h4 id="Java8中另一个小改进"><a href="#Java8中另一个小改进" class="headerlink" title="Java8中另一个小改进"></a>Java8中另一个小改进</h4><p>不同于Java7中根据hash值重新计算桶的下标,Java8通过hash&amp;cap如果为0说明放在low桶中,如果为1,放在high桶中,减小了计算量</p>
<h4 id="代码-1"><a href="#代码-1" class="headerlink" title="代码"></a>代码</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">final</span> Node&lt;K,V&gt;[] resize() &#123;</span><br><span class="line">    Node&lt;K,V&gt;[] oldTab = table;</span><br><span class="line">    <span class="keyword">int</span> oldCap = (oldTab == <span class="keyword">null</span>) ? <span class="number">0</span> : oldTab.length;</span><br><span class="line">    <span class="keyword">int</span> oldThr = threshold;</span><br><span class="line">    <span class="keyword">int</span> newCap, newThr = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">if</span> (oldCap &gt; <span class="number">0</span>) &#123;</span><br><span class="line">        <span class="keyword">if</span> (oldCap &gt;= MAXIMUM_CAPACITY) &#123;</span><br><span class="line">            threshold = Integer.MAX_VALUE;</span><br><span class="line">            <span class="keyword">return</span> oldTab;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span> ((newCap = oldCap &lt;&lt; <span class="number">1</span>) &lt; MAXIMUM_CAPACITY &amp;&amp;</span><br><span class="line">                    oldCap &gt;= DEFAULT_INITIAL_CAPACITY)</span><br><span class="line">            newThr = oldThr &lt;&lt; <span class="number">1</span>; <span class="comment">// double threshold</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">if</span> (oldThr &gt; <span class="number">0</span>) <span class="comment">// initial capacity was placed in threshold</span></span><br><span class="line">        newCap = oldThr;</span><br><span class="line">    <span class="keyword">else</span> &#123;               <span class="comment">// zero initial threshold signifies using defaults</span></span><br><span class="line">        newCap = DEFAULT_INITIAL_CAPACITY;</span><br><span class="line">        newThr = (<span class="keyword">int</span>)(DEFAULT_LOAD_FACTOR * DEFAULT_INITIAL_CAPACITY);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> (newThr == <span class="number">0</span>) &#123;</span><br><span class="line">        <span class="keyword">float</span> ft = (<span class="keyword">float</span>)newCap * loadFactor;</span><br><span class="line">        newThr = (newCap &lt; MAXIMUM_CAPACITY &amp;&amp; ft &lt; (<span class="keyword">float</span>)MAXIMUM_CAPACITY ?</span><br><span class="line">                    (<span class="keyword">int</span>)ft : Integer.MAX_VALUE);</span><br><span class="line">    &#125;</span><br><span class="line">    threshold = newThr;</span><br><span class="line">    <span class="meta">@SuppressWarnings(&#123;&quot;rawtypes&quot;,&quot;unchecked&quot;&#125;)</span></span><br><span class="line">    Node&lt;K,V&gt;[] newTab = (Node&lt;K,V&gt;[])<span class="keyword">new</span> Node[newCap];</span><br><span class="line">    table = newTab;</span><br><span class="line">    <span class="keyword">if</span> (oldTab != <span class="keyword">null</span>) &#123;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; oldCap; ++j) &#123;</span><br><span class="line">            Node&lt;K,V&gt; e;</span><br><span class="line">            <span class="keyword">if</span> ((e = oldTab[j]) != <span class="keyword">null</span>) &#123;</span><br><span class="line">                oldTab[j] = <span class="keyword">null</span>;</span><br><span class="line">                <span class="keyword">if</span> (e.next == <span class="keyword">null</span>)</span><br><span class="line">                    newTab[e.hash &amp; (newCap - <span class="number">1</span>)] = e;</span><br><span class="line">                <span class="keyword">else</span> <span class="keyword">if</span> (e <span class="keyword">instanceof</span> TreeNode)</span><br><span class="line">                    ((TreeNode&lt;K,V&gt;)e).split(<span class="keyword">this</span>, newTab, j, oldCap);</span><br><span class="line">                <span class="keyword">else</span> &#123; <span class="comment">// preserve order</span></span><br><span class="line">                    Node&lt;K,V&gt; loHead = <span class="keyword">null</span>, loTail = <span class="keyword">null</span>;</span><br><span class="line">                    Node&lt;K,V&gt; hiHead = <span class="keyword">null</span>, hiTail = <span class="keyword">null</span>;</span><br><span class="line">                    Node&lt;K,V&gt; next;</span><br><span class="line">                    <span class="keyword">do</span> &#123;</span><br><span class="line">                        next = e.next;</span><br><span class="line">                        <span class="keyword">if</span> ((e.hash &amp; oldCap) == <span class="number">0</span>) &#123;</span><br><span class="line">                            <span class="keyword">if</span> (loTail == <span class="keyword">null</span>)</span><br><span class="line">                                loHead = e;</span><br><span class="line">                            <span class="keyword">else</span></span><br><span class="line">                                loTail.next = e;</span><br><span class="line">                            loTail = e;</span><br><span class="line">                        &#125;</span><br><span class="line">                        <span class="keyword">else</span> &#123;</span><br><span class="line">                            <span class="keyword">if</span> (hiTail == <span class="keyword">null</span>)</span><br><span class="line">                                hiHead = e;</span><br><span class="line">                            <span class="keyword">else</span></span><br><span class="line">                                hiTail.next = e;</span><br><span class="line">                            hiTail = e;</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125; <span class="keyword">while</span> ((e = next) != <span class="keyword">null</span>);</span><br><span class="line">                    <span class="keyword">if</span> (loTail != <span class="keyword">null</span>) &#123;</span><br><span class="line">                        loTail.next = <span class="keyword">null</span>;</span><br><span class="line">                        newTab[j] = loHead;</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">if</span> (hiTail != <span class="keyword">null</span>) &#123;</span><br><span class="line">                        hiTail.next = <span class="keyword">null</span>;</span><br><span class="line">                        newTab[j + oldCap] = hiHead;</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> newTab;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/01/23/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84%E8%99%9A%E6%8B%9F%E5%86%85%E5%AD%98/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/01/23/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84%E8%99%9A%E6%8B%9F%E5%86%85%E5%AD%98/" class="post-title-link" itemprop="url">操作系统的虚拟内存</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-23 12:12:22" itemprop="dateCreated datePublished" datetime="2021-01-23T12:12:22+08:00">2021-01-23</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-04 13:42:02" itemprop="dateModified" datetime="2021-04-04T13:42:02+08:00">2021-04-04</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="虚拟内存的设计目标"><a href="#虚拟内存的设计目标" class="headerlink" title="虚拟内存的设计目标"></a>虚拟内存的设计目标</h2><h3 id="透明"><a href="#透明" class="headerlink" title="透明"></a>透明</h3><p>让运行的程序像是拥有整个物理内存,物理内存的管理由操作系统负责</p>
<h3 id="效率"><a href="#效率" class="headerlink" title="效率"></a>效率</h3><p>操作系统需要保证内存虚拟化在时间和空间上的效率.也即不会导致程序运行太慢,也不会造成太多的内存浪费</p>
<h3 id="保护"><a href="#保护" class="headerlink" title="保护"></a>保护</h3><p>虚拟内存需要保证不同进程之间互相隔离,从而保证一个进程的崩溃不会影响其他进程.</p>
<h2 id="分页与分段"><a href="#分页与分段" class="headerlink" title="分页与分段"></a>分页与分段</h2><h3 id="分页"><a href="#分页" class="headerlink" title="分页"></a>分页</h3><p>将程序分为固定大小的块,每个块存在不同的区域,使用页表定位一条指令具体的存放位置</p>
<p>页表中存放虚拟页号 物理页号</p>
<h4 id="特点"><a href="#特点" class="headerlink" title="特点"></a>特点</h4><p>不容易造成内存浪费,可以将一块较大的区域分割成多个块,分别放置在不同的位置</p>
<p>需要设置好页大小,不能太大,太大会造成页内部的内存浪费.太小会需要更多的页,造成页表变得很大.</p>
<h3 id="分段"><a href="#分段" class="headerlink" title="分段"></a>分段</h3><p>将地址空间分成不同的段,比如代码段 堆段 栈段等,可以将不同的段存储在不同的地方.操作系统使用段寄存器保存各个段的基址和大小.</p>
<h4 id="特点-1"><a href="#特点-1" class="headerlink" title="特点"></a>特点</h4><p>将程序划分为逻辑上独立的内存空间,有利于共享和保护</p>
<h3 id="段页式"><a href="#段页式" class="headerlink" title="段页式"></a>段页式</h3><p>首先将程序分为逻辑上独立的段,再将各个段分为大小相同的页.既有了分段对于内存的保护,又有了分页减小内存浪费的特性.</p>
<h2 id="多级页表"><a href="#多级页表" class="headerlink" title="多级页表"></a>多级页表</h2><h3 id="段页式的缺点"><a href="#段页式的缺点" class="headerlink" title="段页式的缺点"></a>段页式的缺点</h3><ul>
<li>如果堆比较稀疏,会造成比较严重的内存浪费 </li>
<li>页表的大小可以为任意值,因此为页表寻找存储空间将变得十分困难.</li>
</ul>
<p>因此引出多级页表</p>
<h3 id="多级页表的访问过程"><a href="#多级页表的访问过程" class="headerlink" title="多级页表的访问过程"></a>多级页表的访问过程</h3><ul>
<li>访问TLB,如果命中则直接寻址</li>
<li>TLB没有命中,访问页目录,找到页表的位置</li>
<li>访问页表,如果存在位为1,定位具体对应的物理地址</li>
<li>存在位为0,说明页内容存储在磁盘中,需要唤醒操作系统在磁盘中找到相应的信息</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/01/21/Redis%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9F%BA%E4%BA%8E%E5%8D%95%E7%BA%BF%E7%A8%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/01/21/Redis%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9F%BA%E4%BA%8E%E5%8D%95%E7%BA%BF%E7%A8%8B/" class="post-title-link" itemprop="url">Redis为什么基于单线程</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-21 18:05:23" itemprop="dateCreated datePublished" datetime="2021-01-21T18:05:23+08:00">2021-01-21</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-04 13:42:02" itemprop="dateModified" datetime="2021-04-04T13:42:02+08:00">2021-04-04</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="redis为什么基于单线程"><a href="#redis为什么基于单线程" class="headerlink" title="redis为什么基于单线程"></a>redis为什么基于单线程</h2><ul>
<li>redis除了数据持久化,主要是内存读写,CPU运算速度不是性能的瓶颈</li>
<li>基于多线程需要频繁切换进程context,另外线程的互斥也会带来不小开销</li>
<li>基于IO多路复用redis可以较好地处理客户端传来的命令<h2 id="Redis4-0之后也引入了多线程"><a href="#Redis4-0之后也引入了多线程" class="headerlink" title="Redis4.0之后也引入了多线程"></a>Redis4.0之后也引入了多线程</h2></li>
</ul>
<p>多线程可以用来删除规模较大数据.例如del操作可以首先删除key,对于value的释放可以交给另外的线程执行,减少删除大对象带来的开销</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/01/21/IO%E5%A4%8D%E7%94%A8%E7%9A%84select-poll-epoll%E6%A8%A1%E5%9E%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/01/21/IO%E5%A4%8D%E7%94%A8%E7%9A%84select-poll-epoll%E6%A8%A1%E5%9E%8B/" class="post-title-link" itemprop="url">IO复用的select poll epoll模型</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-21 17:19:54" itemprop="dateCreated datePublished" datetime="2021-01-21T17:19:54+08:00">2021-01-21</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-04 13:42:02" itemprop="dateModified" datetime="2021-04-04T13:42:02+08:00">2021-04-04</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="Select"><a href="#Select" class="headerlink" title="Select"></a>Select</h2><p>在调用select之前,需要先将要监听的事件和监听的类型(读完成,写完成,异常)放入指定集合中,之后调用select函数.select函数将会轮询每个事件,最终将满足可读写的事件集合返回</p>
<h3 id="缺点"><a href="#缺点" class="headerlink" title="缺点"></a>缺点</h3><ul>
<li><strong>由于集合的底层是使用数组实现的,所以大小有限制</strong>. 而现在的服务器需要同时处理大量的IO</li>
<li><strong>每次执行select操作的时候,都需要将事件集合复制进操作系统集合</strong>. 事件很多时将会比较耗时</li>
<li><strong>每次select操作都需要轮询所有的fd(文件描述符)</strong>. 也是十分耗时<h2 id="Poll"><a href="#Poll" class="headerlink" title="Poll"></a>Poll</h2>poll与select非常类似,他的改进主要是两个方面: </li>
<li><strong>使用链表代替数组</strong>, 解决了<strong>监听的fd最大长度固定的问题</strong></li>
<li><strong>使用pollfd</strong>, <strong>避免了每次进行select操作都需要复制所有的fd</strong><br>pollfd的类结构如下<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">pollfd</span></span>&#123;</span><br><span class="line">    <span class="keyword">int</span> fd, <span class="comment">// 文件描述符</span></span><br><span class="line">    <span class="keyword">short</span> events, <span class="comment">// 注册的事件类型</span></span><br><span class="line">    <span class="keyword">short</span> revents <span class="comment">// 实际发生的事件(内核填充)</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="Epoll"><a href="#Epoll" class="headerlink" title="Epoll"></a>Epoll</h2>在系统内核中创建一个事件监听表,应用程序直接向内核中添加和删除需要监听的事件,同时提前定义好回调函数,文件读写完成时将直接执行回调函数<h3 id="优点"><a href="#优点" class="headerlink" title="优点"></a>优点</h3></li>
<li><strong>内核中的事件监听表底层基于B+树</strong>, 解决了<strong>长度有限的问题</strong></li>
<li><strong>应用程序直接向内核中添加和删除</strong>, 避免了<strong>多次复制造成的开销</strong></li>
<li><strong>提前定义好回调函数</strong>, 避免了<strong>每次调用select需要遍历所有的事件</strong></li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/01/21/Java-%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%B8%B8%E9%87%8F%E6%B1%A0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/01/21/Java-%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%B8%B8%E9%87%8F%E6%B1%A0/" class="post-title-link" itemprop="url">Java 字符串常量池</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-21 14:23:48" itemprop="dateCreated datePublished" datetime="2021-01-21T14:23:48+08:00">2021-01-21</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-04 13:42:02" itemprop="dateModified" datetime="2021-04-04T13:42:02+08:00">2021-04-04</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="简述"><a href="#简述" class="headerlink" title="简述"></a>简述</h2><h3 id="Java6及之前"><a href="#Java6及之前" class="headerlink" title="Java6及之前"></a>Java6及之前</h3><p>字符串常量池存储在永久代中.new String对象需要指向常量池中的字符串</p>
<h4 id="“1”"><a href="#“1”" class="headerlink" title="“1”"></a>“1”</h4><ul>
<li>在常量池中创建字符串</li>
<li>返回其引用<h4 id="new-String-“1”"><a href="#new-String-“1”" class="headerlink" title="new String(“1”)"></a>new String(“1”)</h4></li>
<li>在常量池中创建字符串</li>
<li>在堆中创建对象,对象内容指向常量池中的字符串</li>
<li>返回引用</li>
</ul>
<h3 id="Java7及之后"><a href="#Java7及之后" class="headerlink" title="Java7及之后"></a>Java7及之后</h3><p>字符串常量池存储在堆中,常量池可以指向堆中已存在的字符串</p>
<h4 id="“1”-1"><a href="#“1”-1" class="headerlink" title="“1”"></a>“1”</h4><p>常量池中既可能存储字符串,也可能存储的是字符串的引用</p>
<h2 id="案例"><a href="#案例" class="headerlink" title="案例"></a>案例</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 程序1</span></span><br><span class="line">String s1 = <span class="keyword">new</span> String(<span class="string">&quot;1&quot;</span>);</span><br><span class="line">s1.intern();</span><br><span class="line">String s2 = <span class="string">&quot;1&quot;</span>;</span><br><span class="line">System.out.println(s1 == s2);</span><br><span class="line"></span><br><span class="line">String s3 = <span class="keyword">new</span> String(<span class="string">&quot;1&quot;</span>) + <span class="keyword">new</span> String(<span class="string">&quot;1&quot;</span>);</span><br><span class="line">s3.intern();</span><br><span class="line">String s4 = <span class="string">&quot;11&quot;</span>;</span><br><span class="line">System.out.println(s3 == s4);</span><br></pre></td></tr></table></figure>
<p>程序1在Java6之前,结果为false, false.在Java7之后结果为false, true</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//程序2</span></span><br><span class="line">String s1 = <span class="keyword">new</span> String(<span class="string">&quot;1&quot;</span>);</span><br><span class="line">s1.intern();</span><br><span class="line">String s2 = <span class="string">&quot;1&quot;</span>;</span><br><span class="line">System.out.println(s1 == s2);</span><br><span class="line"></span><br><span class="line">String s3 = <span class="keyword">new</span> String(<span class="string">&quot;1&quot;</span>) + <span class="keyword">new</span> String(<span class="string">&quot;1&quot;</span>);</span><br><span class="line">String s4 = <span class="string">&quot;11&quot;</span>;</span><br><span class="line">s3.intern();</span><br><span class="line">System.out.println(s3 == s4);</span><br></pre></td></tr></table></figure>
<p>程序2在Java7之后仍然为false, false</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/01/21/Spring-MVC%E8%8E%B7%E5%8F%96%E5%8F%82%E6%95%B0%E7%9A%84%E9%9B%86%E4%B8%AD%E6%96%B9%E5%BC%8F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/01/21/Spring-MVC%E8%8E%B7%E5%8F%96%E5%8F%82%E6%95%B0%E7%9A%84%E9%9B%86%E4%B8%AD%E6%96%B9%E5%BC%8F/" class="post-title-link" itemprop="url">Spring MVC获取参数的集中方式</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-21 14:09:44" itemprop="dateCreated datePublished" datetime="2021-01-21T14:09:44+08:00">2021-01-21</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-04 13:42:02" itemprop="dateModified" datetime="2021-04-04T13:42:02+08:00">2021-04-04</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="Spring-MVC获取Request参数的几种方式"><a href="#Spring-MVC获取Request参数的几种方式" class="headerlink" title="Spring MVC获取Request参数的几种方式"></a>Spring MVC获取Request参数的几种方式</h2><ul>
<li><p>RequestBody 获取方法体中的参数 不可用于get</p>
</li>
<li><p>RequestParam 获取路径中问号后面的数据</p>
<p>  例子： <a target="_blank" rel="noopener" href="http://www.baidu.com/?id">http://www.baidu.com?</a>keyword=1, 可以用来获取keyword参数</p>
</li>
<li><p>PathVariable 获取路径中的数据</p>
<p>  例子： <a target="_blank" rel="noopener" href="http://www.baidu.com/%7Bid%7D">http://www.baidu.com/{id}</a> , 可以获取id参数</p>
</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://shaojunying.github.io/2021/01/21/Get%E5%92%8CPost-cookie%E5%92%8Csession%E5%8C%BA%E5%88%AB/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="邵俊颖">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Shaojunying's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/01/21/Get%E5%92%8CPost-cookie%E5%92%8Csession%E5%8C%BA%E5%88%AB/" class="post-title-link" itemprop="url">Get和Post cookie和session区别</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-21 14:09:02" itemprop="dateCreated datePublished" datetime="2021-01-21T14:09:02+08:00">2021-01-21</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-04-04 13:42:02" itemprop="dateModified" datetime="2021-04-04T13:42:02+08:00">2021-04-04</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="Get和Post区别"><a href="#Get和Post区别" class="headerlink" title="Get和Post区别"></a>Get和Post区别</h1><ul>
<li>Get是从服务端请求资源,而post是向服务端发送资源</li>
<li>Get的参数附在URL后面,Post是存储在消息主体中,相对来说Post更安全一些</li>
<li>Get的的URL有最大长度限制,也就导致了传输的数据不能过大</li>
</ul>
<h1 id="Cookie和Session"><a href="#Cookie和Session" class="headerlink" title="Cookie和Session"></a>Cookie和Session</h1><ul>
<li>Cookie保存在客户端,Session保存在服务端</li>
<li>Session比较难以支持分布式,因为一个服务器不知道另一个服务器中存的session</li>
<li>Cookie不能存储敏感的信息,否则会不安全</li>
<li>Session会增加服务器的内存压力</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><span class="space">&hellip;</span><a class="page-number" href="/page/6/">6</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">邵俊颖</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">55</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">35</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/shaojunying" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;shaojunying" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:shaojunying1@gmail.com" title="E-Mail → mailto:shaojunying1@gmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="https://twitter.com/SHAOJY1999" title="Twitter → https:&#x2F;&#x2F;twitter.com&#x2F;SHAOJY1999" rel="noopener" target="_blank"><i class="fab fa-twitter fa-fw"></i></a>
      </span>
      <span class="links-of-author-item">
        <a href="https://stackoverflow.com/users/10499946/shao-junying" title="StackOverflow → https:&#x2F;&#x2F;stackoverflow.com&#x2F;users&#x2F;10499946&#x2F;shao-junying" rel="noopener" target="_blank"><i class="fab fa-stack-overflow fa-fw"></i></a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">京ICP备2020041459号 </a>
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">邵俊颖</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>

<script src="/js/bookmark.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>




  
<script src="/js/local-search.js"></script>













  

  

</body>
</html>
